package com.exam.controller;

import com.exam.dto.ActionResult;
import com.exam.po.MultiQuestion;
import com.exam.service.MultiQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName MultiQuestionController
 * @Description TODO
 * @action luoliang
 * @Data 2021/1/12 15:15
 * @Version 1.0
 */

@RestController
@RequestMapping("/api")
public class MultiQuestionController  {

    @Autowired
    private MultiQuestionService multiQuestionService;

    /**
     * 增加
     * @param record
     * @return
     */
    @RequestMapping(value = "/MultiQuestion",method = RequestMethod.POST)
    public ActionResult AddMulti(@RequestBody  MultiQuestion record){
        //System.out.println(record);
        //System.out.println("213");
        int insert = multiQuestionService.Insert(record);
        System.out.println(insert);
        if (insert>-1){
            ActionResult success = new ActionResult(200, "success", insert);
            //System.out.println(123456);
            return success;
        }else{
           // System.out.println(1456);
            ActionResult error = new ActionResult(203, "error", null);
            return error;
        }
    }
    @RequestMapping(value = "/multiQuestionId",method = RequestMethod.GET)
    public ActionResult FindMulti(Integer questionid){
        MultiQuestion multiQuestion = multiQuestionService.SelectByPrimaryKey(questionid);
        if (multiQuestion != null){
            ActionResult success = new ActionResult(200, "success", multiQuestion);
            return success;
        }else {
            ActionResult error = new ActionResult(203, "error", null);
            return error;
        }
    }
}
